ValkyrAI Workflow Engine
The ValkyrAI Workflow Engine is a powerful component that enables the creation, management, and execution of automated workflows. It provides a flexible and extensible framework for defining business processes, tasks, and execution modules that can be orchestrated to perform a wide range of operations.
Architecture
The ValkyrAI Workflow Engine works via a Quartz scheduler that executes workflows on a schedule at intervals. Workflows can also be run and managed on demand via REST endpoints.
The architecture consists of the following key components:
- Workflows: Define the overall process flow and contain a series of tasks
- Tasks: Individual units of work within a workflow
- Execution Modules: Specialized components that perform specific functions
- Data Handlers: Components that process and transform data during workflow execution
When run by HeimdaLLM and via a collection of basic Execution Modules and in conjunction with OpenAPI Specs, the Workflow Engine is capable of nearly any task of any complexity.
Key Features
Workflow Management
- Create, update, and delete workflows
- Start, stop, and pause workflow execution
- Monitor workflow status and progress
- Schedule workflows using CRON expressions
Task Management
- Define tasks with specific execution parameters
- Set task dependencies and execution order
- Monitor task execution status
- Handle task failures and retries
Execution Modules
The Workflow Engine includes several built-in execution modules:
- Email Module: Send and receive emails
- Files Module: Manage file operations
- Medium Module: Interact with Medium publishing platform
- Threads Module: Manage thread-based operations
You can also create custom execution modules to extend the functionality of the Workflow Engine.
Workflow Definition
Workflows are defined using a JSON-based configuration format that specifies the tasks, their dependencies, and execution parameters. Here's an example of a simple workflow definition:
{
"name": "Document Processing Workflow",
"description": "Process incoming documents and extract information",
"schedule": "0 0/30 * * * ?", // Run every 30 minutes
"tasks": [
{
"id": "fetch-documents",
"type": "files",
"parameters": {
"source": "/incoming-documents",
"pattern": "*.pdf"
}
},
{
"id": "process-documents",
"type": "document-processor",
"dependsOn": ["fetch-documents"],
"parameters": {
"extractText": true,
"extractMetadata": true
}
},
{
"id": "send-notification",
"type": "email",
"dependsOn": ["process-documents"],
"parameters": {
"to": "admin@example.com",
"subject": "Document Processing Complete",
"template": "document-processing-notification"
}
}
]
}
REST API
The Workflow Engine exposes a comprehensive REST API for managing workflows, tasks, and execution modules. Here are some of the key endpoints:
GET /workflows
: List all workflowsPOST /workflows
: Create a new workflowGET /workflows/{id}
: Get workflow detailsPUT /workflows/{id}
: Update a workflowDELETE /workflows/{id}
: Delete a workflowPOST /workflows/{id}/start
: Start a workflowPOST /workflows/{id}/stop
: Stop a workflowGET /workflows/{id}/status
: Get workflow statusGET /tasks
: List all tasksPOST /tasks
: Create a new taskGET /execution-modules
: List available execution modules
Integration with Other ValkyrAI Components
The Workflow Engine integrates seamlessly with other ValkyrAI components:
- ThorAPI: Workflows can interact with APIs generated by ThorAPI
- SecureFieldKMS: Sensitive data in workflows is protected using SecureField encryption
- HeimdaLLM: AI-powered decision making and content generation within workflows
- GridHeim: Data processing and spreadsheet operations
Getting Started
To start using the ValkyrAI Workflow Engine, follow these steps:
- Ensure you have ValkyrAI properly installed and configured
- Create a workflow definition using the JSON format
- Use the REST API to create and manage your workflows
- Configure the necessary execution modules for your workflow tasks
- Start your workflow and monitor its execution
For more detailed information on specific execution modules, refer to the documentation for each module:
Best Practices
- Break down complex processes into smaller, manageable tasks
- Use descriptive names for workflows and tasks
- Set appropriate error handling and retry mechanisms
- Monitor workflow execution regularly
- Test workflows thoroughly before deploying to production
- Document workflow configurations and dependencies